{% extends 'user/base.html' %}

{% block title %}
    全部分类
{% endblock %}

{% block head %}
    <link href="{{ url_for('static',filename='css/base.css') }}" rel="stylesheet" type="text/css"/>
    <link href="{{ url_for('static',filename='css/product.css') }}" rel="stylesheet" type="text/css"/>
    <link href="{{ url_for('static',filename='css/classify.css') }}" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="{{ url_for('static',filename='js/dotdotdot.js') }}"></script>
{% endblock %}

{% block main %}
    <div class="container productList">
        <div class="span6">
            <div class="hotProductCategory">
                {% for category in categorys %}
                    <dl>
                        <dt>
                            {% if categorySecond.category.id == category.id or category_my.id == category.id %}
                                <a href="{{ url_for('product.getClassify',cid=category.id) }}"
                                   class="category"> {{ category.cname }}</a>
                            {% else %}
                                <a href="{{ url_for('product.getClassify',cid=category.id) }}"> {{ category.cname }}</a>
                            {% endif %}

                        </dt>
                        {% for categorysecond in category.categoryseconds %}
                            <dd>
                                {% if categorySecond.id == categorysecond.id %}
                                    <a href="{{ url_for('product.getClassify',csid=categorysecond.id) }}"
                                       class="categorysecond">{{ categorysecond.csname }}</a>
                                {% else %}
                                    <a href="{{ url_for('product.getClassify',csid=categorysecond.id) }}">{{ categorysecond.csname }}</a>
                                {% endif %}
                            </dd>
                        {% endfor %}
                    </dl>
                {% endfor %}
            </div>
        </div>
        <div class="span18 last other_area_last">
            <input type="hidden" id="brandId" name="brandId" value="">
            <input type="hidden" id="promotionId" name="promotionId" value="">
            <input type="hidden" id="orderType" name="orderType" value="">
            <input type="hidden" id="pageNumber" name="pageNumber" value="1">
            <input type="hidden" id="pageSize" name="pageSize" value="20">

            <div id="result" class="result table clearfix">
                <ul class="my_list">
                    {% for product in products %}
                        <li>
                            <a href="{{ url_for('product.detail',id=product.id) }}" target="_blank">
                                <img src="{{ product.head_img }}" width="170" height="170"
                                     style="display: inline-block;"/>

                                <span class="product_title">
                                    {{ product.pname }}
                                    </span>

                                <span class="price">
                                        商城价： ￥ {{ product.new_price }}元
                                    </span>
                            </a>
                        </li>
                    {% endfor %}
                </ul>
            </div>
            <div class="row pad-15">
                <div class="col-md-12">
                    <nav class="pagination-outer" aria-label="Page navigation">
                        {% if products|length > 0 %}
                            <ul class="pagination my_pagination">
                                {% for page in range(pages) %}
                                    {% if (page+1) == currentPage %}
                                        <li class="page-item active"><a class="page-link"
                                                                        href="{{ url_for('product.getClassify',pageNum=page,cid=category_my.id,csid=categorySecond.id) }}">
                                            {{ page+1 }}</a></li>
                                    {% else %}
                                        <li class="page-item"><a class="page-link"
                                                                 href="{{ url_for('product.getClassify',pageNum=page,cid=category_my.id,csid=categorySecond.id) }}">
                                            {{ page+1 }}</a></li>
                                    {% endif %}
                                {% endfor %}
                                </li>
                            </ul>
                        {% endif %}
                    </nav>
                </div>
            </div>
        </div>
    </div>
    </div>
    <script>
        $(function () {
            $(".product_title").dotdotdot();
            if ($("#result .my_list li").length == 0) {
                $('#result').addClass('null_page')
            }
        })
    </script>
{% endblock %}